package com.eddie.adapter.objectadapter;

import com.eddie.adapter.objectadapter.Voltage220V;

/**
 * 适配器类
 *
 * @author Eddie
 * @date 2022/07/28 12:24
 **/
public class VoltageAdapter implements IVoltage5V {
    /**
     * 关联关系中的聚合关系
     */
    private Voltage220V voltage220V;

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int output5V() {
        int desV = 0;
        //获取到220V电压
        if (voltage220V != null) {
            int src = voltage220V.output();
            System.out.println("使用对象适配器进行适配~");
            desV = src / 44;
        }
        //转成5V
        return desV;
    }
}
